<template>
	<view>
		<!-- 页首 -->
		<zw-header></zw-header>
		<!-- 左侧导航栏 -->
		<menu-wrapper active-index="2-1" style="background-color: #fff;padding: 0;">
			<view
				style="height: 1400rpx;display: flex;justify-content: space-between;align-items: flex-start;margin-top: 60rpx;">
				<view style="width: 100%;">
					<view
						style="background: #F0F0F0;height: 1000rpx;display: flex;justify-content: center;align-items: center;">
						<view style="display: flex;justify-content: center;align-items: center;">
							<image :src="imageList[index]" style="width: 900rpx;height: 900rpx;" mode="heightFix"></image>
						</view>
					</view>
					<view style="display: flex;justify-content: center;align-items: center;margin-top: 20rpx;">
						<view>
							<image v-for="(item ,key) in imageList" :key="key" @click="index=key" :src="item" :style="index==key?'border: 3px solid #002BFF;':''"
								style="width: 100rpx;height: 100rpx;border-radius: 14px;margin:10rpx;">
							</image>
						</view>
					</view>
				</view>
				<view class="padding" style="display: block;width: 40%;margin-left: 20rpx;">
					<view style="display: flex;justify-content:space-between;align-items: flex-start;width: 100%;">
						<view style="display: flex;justify-content: flex-start;align-items: flex-start;">
							<image :src="user.avator" style="height: 50rpx; width: 50rpx;border-radius: 50%;"></image>
							<view class="marginLeft text-light-black-18" @click="gotoUser">{{user.name}}</view>
							<view class="bigEmpty">
								<view v-show="!user.focused" style="width: 150rpx;"
									class="btnBlue line textwhite8 marginLeft" @click="foucus(user) ">关注</view>
								<view v-show="user.focused" style="width: 150rpx;"
									class="btnBlue line textwhite8 marginLeft" @click="foucus(user) ">已关注</view>
							</view>

						</view>
						<view
							style="border: 1px solid #B5B5B5;border-radius:100rpx;width: 100rpx;display: flex;justify-content: space-between;align-items: center;">
							<image @click="showMenu = !showMenu" style="width: 50rpx;" mode="widthFix"
								src="/static/image/user/credit/s.png"></image>
						</view>
					</view>
					<view style="display: flex;justify-content: flex-start;align-items:center;margin-top: 50rpx;">
						<view
							style="background: linear-gradient(104deg, #E8B45A 2%, rgba(235, 217, 100, 0.75) 97%, rgba(232, 203, 17, 0.51) 97%);font-size: 14px;padding: 10rpx 20rpx 10rpx 20rpx">
							AI生成</view>
						<view style="color: #000000;font-size: 18px;font-weight: bold;margin-left: 40rpx;">{{name}}
						</view>
					</view>
					<view v-show="content" class="padding">{{content}}</view>

					<view v-show="goodContent" class="marginTop bg-gray-circle-rect  padding">
						<view class="line">
							<view class="bigEmpty"><text class="textblack18   ">正向指令 </text></view>
							<view><text class="textblack18 ">复制 </text></view>
						</view>
						<view class="lineGray marginTop"></view>
						<view class="   textblack14 marginTop">
							<text> {{goodContent}}</text>
						</view>
					</view>
					<view v-show="badContent" class="marginTop bg-gray-circle-rect  padding">
						<view class="line">
							<view class="bigEmpty"><text class="textblack18   ">反向指令 </text></view>
							<view><text class="textblack18 ">复制 </text></view>
						</view>
						<view class="lineGray marginTop"></view>
						<view class="   textblack14 marginTop">
							<text> {{badContent}}</text>
						</view>
					</view>
					<view class="marginTop bg-gray-circle-rect padding">
						<text class="textblack18 " style="font-size: 16px;font-weight: 500;"> 创作信息 </text>
						<view class="lineGray marginTop"></view>
						<view class="textblack14" style="line-height: 50rpx; color: #3D3D3D; font-size: 26rpx;">
							<view class="marginTop"> <text>创作者</text> <text class=" floatRight">{{user.name}}</text>
							</view>
							<view class="marginTop"> <text>创建时间</text> <text class=" floatRight">{{createTime}}</text>
							</view>
							<view class="marginTop"> <text>模型主题</text> <text class=" floatRight">{{module}}</text>
							</view>
							<view class="marginTop"> <text>画面尺寸</text> <text class=" floatRight">{{size}}</text></view>
							<view v-show="style" class="marginTop"> <text>风格选择</text> <text
									class=" floatRight">{{style}}</text>
							</view>
							<view v-show="false" class="marginTop"> <text>Seed(种子)</text> <text
									class=" floatRight">无</text></view>
							<view class="marginTop"> <text>图片提示</text>
								<text v-if="attachImages.length>0&&attachImages[0]" @click="goBig()"
									class=" textblue14 floatRight">查看</text>
								<text v-else="attachImages.length==0" class="  floatRight">无</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view>


				<view class="line marginTop marginLeft marginRight">
					<view style="font-size: 28rpx;">评论：{{commentList.length}}条</view>
					<view class="bigEmpty"></view>
					<view style="font-size: 24rpx; color: #666;">举报</view>
				</view>
				<view class="lineGray marginTop"></view>
				<view class="column padding-large" v-show="commentList.length==0" style="color: #999999;font-size: 36rpx;">
					<view>
						<image class="image-small" src="/static/image/info/nocomment.png"></image>
					</view>
					<view>暂时还没有评论</view>
					<view>快来说说你的看法吧</view>
				</view>
				<view v-show="commentList.length!=0">
					<view v-for="(item,index) in commentList">
						<view class="padding">
							<view class="line" @click="commendItemClick(item,item.child)">
								<image class="image-head-small" :src="item.user.avator"></image>
								<view class="marginLeft">{{item.user.name}}</view>
								<view class="marginLeft bigEmpty">{{item.createTime}}</view>
							</view>
							<view class="marginTop">{{item.content}}</view>
							<view class="marginLeft bg-gray-circle-rect marginTop" v-show="item.child.length!=0"
								@click="commendItemClick(inItem,item.child)">
								<view class="padding " v-for="(inItem,index) in item.child">
									<view class="line">
										<image class="image-head-small" :src="inItem.user.avator"></image>
										<view class="marginLeft">{{inItem.user.name}}</view>
										<view class="marginLeft bigEmpty">{{inItem.createTime}}</view>
									</view>
									<view class="marginTop">{{inItem.content}}</view>
									<view class="lineGray marginTop"></view>
								</view>
							</view>
							<view class="padding"></view>
							<view class="lineGray marginTop"></view>
						</view>
					</view>
				</view>
				<view style="height: 150rpx;"></view>
				<view class=" column bgWhite width100 ">

					<view class="lineGray"></view>
					<view class="padding line  width100  " style="display: flex;justify-content: space-between;align-items: center;">

						<view style="display: flex;justify-content: flex-start;align-items: center;">
							<view class="column marginLeft " style="margin-left: 40rpx;">
								<image v-if="item.loved" @click="love(item)" class="icon-normal"
									src="/static/image/info/star1.png">
								</image>
								<image v-else @click="love(item)" class="icon-normal" src="/static/image/info/star.png">
								</image>
								<view>
									{{item.loveNum}}
								</view>
							</view>
							<view class="column marginLeft " style="margin-left: 40rpx;">
								<image v-if="item.loved" @click="love(item)" class="icon-normal"
									src="/static/image/info/love1.png">
								</image>
								<image v-else @click="love(item)" class="icon-normal" src="/static/image/info/love.png">
								</image>
								<view>
									{{item.loveNum}}
								</view>
							</view>
							
							<view class="column marginLeft " style="margin-left: 40rpx;">
								
								<image class="icon-normal" src="/static/image/info/msg.png">
								</image>
								<view>
									{{commentList.length}}
								</view>
							</view>
							<view class="column margin-left-3">
								<view class="line paddingSmall bg-more-color-round-rect textwhite14  "
									style="width: 150rpx;" @click.stop="sameProduct(item)"> &nbsp;一键同款&nbsp;</view>
							</view>
						</view>
						<view class="margin-left-3 bigEmpty line marginRight"
							style="border: 1px solid #C4BFBF;background: #F0F0F0;border-radius: 100px;">
							<text v-show="comment[0]==' '">
								{{replayName}}
							</text>
							<input class="bigEmpty" style="padding-left: 40rpx;" placeholder="说点啥吧..." v-model="comment" @input="onInput" />
							<div style="width: 100rpx;" class=" paddingSmall bg-gray-circle-rect line" @click="send()">
								发送</div>
						</view>
					</view>

				</view>
			</view>
		</menu-wrapper>
		<!-- 页脚 -->
		<!-- <zw-footer></zw-footer> -->
		<!-- <fui-landscape :show="show" :closable="closable" @close="closePopup">
			<view class="fui-ani__box"
				style="background-color: #fff;border-radius: 28rpx;width: 850rpx;height: 900rpx;">
				
			</view>
		</fui-landscape> -->
	</view>
</template>

<script>
	import menuWrapper from '@/components/user/common/menu-wrapper.vue';
	import centerConfig from '@/common/config/user/center.config.js';
	import onYangWxTable from '@/components/onYang-wxTable/onYang-wxTable.vue';
	import {
		mapState
	} from 'vuex';

	export default {
		components: {
			menuWrapper,
			onYangWxTable
		},
		data() {
			return {
				index:0,
				...centerConfig,
				showMenu: false, //是否展示menu列表
				menuList: [{
						icon: '',
						title: '分享'
					},
					{
						icon: '',
						title: '置顶'
					},
				],
				height: "90vw",
				type: 0,
				id: 0,
				imageList: [],
				attachImages: [],
				sizeTab1Index: 1,
				sizeTab2Index: 1,
				styleIndex: 1,
				moduleIndex: 1,
				goodContent: "",
				badContent: "",
				name: "",
				content: "",
				createTime: "",
				author: "",
				module: "",
				size: "",
				style: "",
				returnData: null,
				plateUserId: "",
				user: {},
				commentList: [],
				comment: "",
				item: {},
				replayName: "",
				replayId: 0,
				replayList: [],
				id: 0,
			}
		},
		computed: {
			...mapState(['loginUser']),
			currentTime() {
				const currentHour = new Date().getHours();
				const timeQuantums = ['凌晨', '上午', '下午', '晚上'];
				return timeQuantums[Math.floor(currentHour / 6)];
			}
		},
		onLoad(op) {
			this.id = op.id;
			this.getInfo();
			this.queryComment()
			this.$store.commit('tab', 0);

		},
		onReady() {
			let that = this;
			const query = uni.createSelectorQuery();
			//获取宽度
			// query.select('.item').fields({
			// 	size: true
			// }, (res) => {
			// 	console.log('item', res)
			// 	that.width = res.width;
			// 	const height = res.height;
			// }).exec();
		},
		methods: {
			goBig() {
				// uni.navigateTo({
				// 	url:"/pages/Test/Test?images="+this.imageList
				// })
				uni.previewImage({
					urls: this.attachImages,
					current: 0

				})

			},
			queryComment() {
				const url = getApp().globalData.apiUrl + "/api/v1/comment/all"
				const that = this
				this.$util.request('/api/v1/comment/all', {
					pictureCollectionId: this.id,
					size: 100
				}, (res) => {
					console.log('comment', res)
					that.commentList = res.data
				}, true);
			},
			getInfo() {
				const that = this;
				this.$util.request("/api/v1/pictureCollection/" + this.id, {}, (res) => {
					console.log('pictureCollection', res)
					that.item = res.data;
					that.user = res.data.user
					that.returnData = res.data.job;
					that.name = res.data.name;
					that.content = res.data.content;
					that.imageList = res.data.formatImages
					console.log('imageList', that.imageList)
					that.sizeTab1Index = res.data.job.width2height
					if (!that.sizeTab1Index) {
						that.sizeTab1Index = 1
					}
					that.createTime = res.data.job.createTime
					that.moduleIndex = res.data.job.module
					that.styleIndex = res.data.job.style
					that.goodContent = res.data.job.cmd
					that.attachImages = res.data.job.attachImages
					var size = "1:1";
					var sizeArray = [
						"1:1",
						"1:1",
						"1:2",
						"4:3",
						"3:4",
						"16:9",
						"9:16"
					]
					that.size = sizeArray[that.sizeTab1Index]
					var module = "精彩"
					var moduleArray = [
						"1:1",
						"1:1",
						"1:2",
						"1:2",
						"精彩",
						"细腻",
						"动漫",
						"创意",
						"照片"
					]

					that.module = moduleArray[that.moduleIndex]
					console.log(that.module)
					var style = "长焦镜头"
					var styleArray = [
						"长焦镜头",
						"长焦镜头",
						"手绘背景",
						"CG数字渲染",
						"哑光颜",
						"X光片",
						"矢量设计海报",
						"极简线条画",
						"炭笔画",
						"更多"
					]
					that.style = styleArray[that.styleIndex]
					// that.setH()
				}, true);

			},
			closePopup() {
				this.show = false
			},
			goUrl(url) {
				uni.navigateTo({
					url: url,
					fail(err) {
						console.log(err)
					}
				})
			},
			clickCard(index) {
				this.cardIndex = index;
				// this.page = 0;
				// this.promos = [];
				// this.findPicture();
			},
			clickOption(index) {
				this.tabIndex = index;
				// this.page = 0;
				// this.promos = [];
				// this.findPicture();
			},
		}
	}
</script>

<style lang="scss">
	.card {
		background: #2C2C2C;
		margin: 40rpx;
		border-radius: 30rpx;
	}

	.card3 {
		color: #885DD6;
		background: linear-gradient(114deg, #D3C2FF 5%, #D3BAFC 45%, #AB94FE 87%);
	}

	.card2 {
		color: #C08049;
		background: radial-gradient(123% 123% at 0% 10%, #FFECC1 0%, #EAA771 99%);
	}

	.card1 {
		color: #7B91A5;
		background: radial-gradient(55% 55% at 13% 5%, #D8E5EA 0%, #C9D9DE 100%);
	}

	.lable {
		font-family: 思源黑体;
		font-size: 16px;
		font-weight: bold;
		line-height: normal;
		text-align: center;
		display: flex;
		align-items: center;
		letter-spacing: 0em;

		color: #666666;
	}

	.active {
		font-family: 思源黑体;
		font-size: 16px;
		font-weight: bold;
		line-height: normal;
		display: flex;
		align-items: center;
		letter-spacing: 0em;
		border-bottom: 2px solid #080808;
		color: #000000;
	}

	.banner {
		width: 100%;
		height: 200px;
		margin: 0 auto;
		display: flex;
		justify-content: center;
	}

	.avatar {
		width: 100px;
		height: 100px;
		padding: 4px;
		border: 3px solid #FFFFFF;
		border-radius: 100px;
		object-fit: fill;
	}

	.card-header {
		display: block;
		width: 100%;
		// padding-top: 24px;
		// justify-content: space-between;
		@extend %flex-align-center;

		.left {
			.user-info {
				text-align: center;
				color: #FFFFFF;

				.user-name {
					font-family: Source Han Sans;
					font-size: 24px;
					font-weight: bold;
				}

				.tip {
					font-family: Source Han Sans;
					font-size: 16px;
					font-weight: normal;
					font-feature-settings: "kern" on;
					color: #FFFFFF;
				}

				.link {
					display: inline-block;
					font-size: 12px;
					margin-top: 10px;
					color: $color-primary;
				}
			}
		}

		.right {
			margin-top: 170rpx;

			.item {
				@extend %flex-align-center;
				background: #1D1D1F;
				border-radius: 40rpx;
				padding: 0 34rpx 0 34rpx;
				// margin-left: 66rpx;
				color: #757575;
				display: block;
				text-align: center;

				.value {
					font-family: HarmonyOS Sans SC;
					font-size: 18px;
					font-weight: bold;
					line-height: 35px;
					text-align: center;
					letter-spacing: 0px;
					color: #000000;
				}

				.name {
					text-align: left;
					font-family: Source Han Sans;
					font-size: 36rpx;
					font-weight: bold;
					font-feature-settings: "kern" on;
					color: #FFFFFF;
				}
			}

		}
	}

	.card-body {
		display: flex;
		flex-wrap: wrap;
		margin-top: 5px;
		padding-top: 50px;
		border-top: 1px solid $border-color;

		.button {
			margin-bottom: 60px;
			@extend %flex-align-center;

			.btn-icon {
				width: 100px;
				height: 100px;
				border-radius: 50%;
			}

			.right {
				width: 276px;
				margin-left: 20px;

				.top {
					@extend %flex-align-center;
					font-size: 18px;
					font-weight: 400;

					.name {
						color: #757575;
					}

					.value {
						color: $color-primary;
					}
				}

				.link {
					line-height: 1.8;
					@extend %flex-align-center;
					color: #757575;
					cursor: pointer;

					&:hover {
						color: $color-primary;
					}

					.icon {
						font-weight: bold;
					}
				}
			}
		}
	}
</style>